import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 07 - 29
 * Time: 9:31
 */
//牛客AB5 点击消除
public class Solution2 {
    //法一
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s = in.nextLine();
            int i  = 0;
            int index = -1;
            StringBuilder stringBuilder = new StringBuilder();
            while(i < s.length()) {
                if(index == -1 || stringBuilder.charAt(index) != s.charAt(i)) {
                    stringBuilder.append(s.charAt(i));
                    i++;
                    index++;
                }else {
                    stringBuilder.deleteCharAt(index);
                    i++;
                    index--;
                }
            }
            if(index == -1) {
                System.out.println('0');
            }
            System.out.println(stringBuilder);
        }
    }

    //法二
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String s = in.nextLine();
            Stack<Character> stack1 = new Stack<>();
            Stack<Character> stack2 = new Stack<>();
            for (int i = 0; i < s.length(); i++) {
                char ch = s.charAt(i);
                if(stack1.isEmpty() || ch != stack1.peek()) {
                    stack1.push(ch);
                }else {
                    stack1.pop();
                }
            }
            if(stack1.isEmpty()) {
                System.out.println('0');
            }else {
                while(!stack1.isEmpty()) {
                    stack2.push(stack1.pop());
                }
                while(!stack2.isEmpty()) {
                    System.out.print(stack2.pop());
                }
            }
        }
    }
}
